import Vue from "vue";

import Vuex from "vuex";
import actions from "./actions.js";
import mutations from "./mutations.js";
import shop from "./modules/shop.js";
import cart from "./modules/cart.js";
import info from "./modules/info.js";
Vue.use(Vuex);
/*
 strict: true,
 1. 检查状态的修改是否是通过 mutations
 2. 如果不是通过mutations修改报错（警告级别）
 前端项目环境
 1. 开发环境 npm run serve  
    process.env.NODE_ENV=development
 2. 生产环境 npm run build
    process.env.NODE_ENV=production
 为什么 strict: process.env.NODE_ENV === "development" ？？
  1. 希望这个检查在开发环境下生效在生产环境下关闭
  2. 严格模式的检查特别消耗运行资源
*/
export default new Vuex.Store({
  strict: process.env.NODE_ENV === "development",
  state: {
    title: "root",
    avatar: "a.png",
    wellcome: "wellcome haer",
  },
  getters: {
    getTitle: (state) => state.title + "!!",
    fullName: (state) => state.title + "jack li",
  },
  mutations,
  actions,
  modules: {
    shop,
    cart,
    info,
  },
});
